package ca.seia.comp6521.a2.itemsetstorage;

public class IntPair implements Comparable<IntPair>, ExternilizableItems {

	private int valOne;
	private int valTwo;
	
	public IntPair(int valOne, int valTwo) {
		this.valOne = valOne;
		this.valTwo = valTwo;
	}
	
	public int getValOne() {
		return valOne;
	}

	public void setValOne(int valOne) {
		this.valOne = valOne;
	}

	public int getValTwo() {
		return valTwo;
	}

	public void setValTwo(int valTwo) {
		this.valTwo = valTwo;
	}


	@Override
	public String toString() {
		return "IntPair [valOne=" + valOne + ", valTwo=" + valTwo + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + valOne;
		result = prime * result + valTwo;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		IntPair other = (IntPair) obj;
		if (valOne != other.valOne)
			return false;
		if (valTwo != other.valTwo)
			return false;
		return true;
	}

	@Override
	public int compareTo(IntPair o) {
		if(this.getValOne() == o.getValOne() && this.getValTwo() == o.getValTwo()) {
			return 0;
		} else if (this.getValOne() > o.getValOne() || this.getValOne() == o.getValOne() && this.getValTwo() > o.getValTwo()) {
			return 1;
		} else {
			return -1;
		}
	}

	@Override
	public String toExternalFormat() {
		return this.getValOne() + " " + this.getValTwo();
	}
	
}
